home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
fish
/
676-700
/
680
/
sattrack
/
ifflib20.lzh
/
Examples
/
Expander.mod
< prev
next >
Wrap
Text File
|
1990-07-31
|
4KB
|
135 lines
(* ---------------------------------------------------------------------------
Expander.mod - stores IFF-ILBMs in uncompressed format
Requires Christian A. Weber's "iff.library" and the appropriate
DEFINITION MODULE which can be found in the library distribution.
By Olivier Schraner, Roggenweg 6, 5036 Oberentfelden/AG, Switzerland
for A+L's "M2Amiga" Modula-2 Compiler V3.3
VER 2 REV 04 on 31-Jul-90 (first public release)
This is public domain - hack it up as you please!
--------------------------------------------------------------------------- *)
MODULE Expander;
FROM SYSTEM IMPORT ADR,ADDRESS;
FROM Arguments IMPORT NumArgs,GetArg;
FROM Arts IMPORT Assert,CurrentLevel,Terminate;
FROM Graphics IMPORT LoadRGB4,ScrollVPort;
FROM Intuition IMPORT OpenScreen,CloseScreen,NewScreen,ScreenPtr,
ScreenFlags,ScreenFlagSet;
FROM Terminal IMPORT WriteString,WriteLn;
IMPORT IFF;
VAR
argc : INTEGER;
argv : ARRAY [0..255] OF CHAR;
arglen : INTEGER;
cnt : INTEGER;
ifffile : ADDRESS;
bmhd : IFF.BitMapHeaderPtr;
ns : NewScreen;
scr : ScreenPtr;
coltab : ARRAY [0..63] OF CARDINAL;
numcol : LONGINT;
PROCEDURE WriteErr(err : INTEGER);
BEGIN (* WriteErr *)
CASE err OF
IFF.cantOpenFile : WriteString("Couldn't open file!") |
IFF.readError : WriteString("Error reading file!") |
IFF.noMem : WriteString("Not enough memory!") |
IFF.notIFF : WriteString("Not an IFF file!") |
IFF.writeError : WriteString("Error writing file!") |
IFF.noILBM : WriteString("Not an IFF-ILBM file!") |
IFF.noBMHD : WriteString("Contains no BMHD chunk!") |
IFF.noBODY : WriteString("Contains no BODY chunk!") |
IFF.tooManyPlanes : WriteString("BODY has more planes than your BitMap!") |
IFF.unknownCompression: WriteString("Unknown compression algorithm!") |
101 : WriteString("Unable to open screen!") |
102 : WriteString("Contains no CMAP chunk!")
END; (* CASE *)
WriteLn
END WriteErr;
PROCEDURE InitNS();
BEGIN (* InitNS *)
WITH ns DO
leftEdge:=0; topEdge:=0; width:=bmhd^.w; height:=bmhd^.h;
depth:=INTEGER(bmhd^.nPlanes); detailPen:=0; blockPen:=0;
viewModes:=IFF.GetViewModes(ifffile);
type:=ScreenFlagSet{wbenchScreen..sf3,screenBehind,screenQuiet};
font:=NIL; defaultTitle:=NIL; gadgets:=NIL; customBitMap:=NIL;
END (* WITH *)
END InitNS;
BEGIN (* Expander *)
WriteString("Expander v2.03 1990 by Finch of Nightmare Prod."); WriteLn;
argc:=NumArgs();
IF argc<1 THEN
WriteString("Usage: Expander Files/..."); WriteLn;
Terminate(CurrentLevel())
END; (* IF *)
GetArg(1,argv,arglen);
IF argv[0]="?" THEN
WriteString("Usage: Expander Files/..."); WriteLn;
Terminate(CurrentLevel());
END; (* IF *)
FOR cnt:=1 TO argc DO
GetArg(cnt,argv,arglen);
WriteString(argv); WriteString(": ");
ifffile:=IFF.OpenIFF(ADR(argv));
IF ifffile=NIL THEN
WriteErr(IFF.IFFError());
ELSE
bmhd:=IFF.GetBMHD(ifffile);
IF bmhd=NIL THEN
WriteErr(IFF.IFFError());
ELSE
InitNS();
scr:=OpenScreen(ns);
IF scr=NIL THEN
WriteErr(101);
ELSE
IF NOT(IFF.DecodePic(ifffile,ADR(scr^.bitMap))) THEN
WriteErr(IFF.IFFError());
ELSE
numcol:=IFF.GetColorTab(ifffile,ADR(coltab));
IF numcol=0 THEN
WriteErr(102);
ELSE
IFF.CloseIFF(ifffile); ifffile:=NIL;
LoadRGB4(ADR(scr^.viewPort),ADR(coltab),INTEGER(numcol));
ScrollVPort(ADR(scr^.viewPort));
IF NOT(IFF.SaveBitMap(ADR(argv),ADR(scr^.bitMap),
scr^.viewPort.colorMap^.colorTable,
IFF.CompressionFlagSet{})) THEN
WriteErr(IFF.IFFError());
ELSE
WriteString("successfully expanded."); WriteLn;
END (* IF *)
END (* IF *)
END (* IF *)
END (* IF *)
END (* IF *)
END; (* IF *)
IF ifffile#NIL THEN IFF.CloseIFF(ifffile); END;
IF scr#NIL THEN CloseScreen(scr); END
END (* FOR *)
END Expander.